<?php
session_start();
if (isset($_SESSION['userid']) && $_SESSION['level']!=2)
{
	header ("location: login.php");
	exit();
}

?>
<?php
include("includes/top_user.php");
?>
<?php
include("includes/connect.php");
$id=$_GET['typeid'];
$sql="select * from type_category where maloai='".$id."' ";
mysql_query("set names 'utf8'");
$query=mysql_query($sql);
$row=mysql_fetch_array($query);
if(isset($_POST['ok']))
{
	
	if($_POST['tb_maloai'] == "") { echo "Please enter your type id"; }
	else{ $t = $_POST['tb_maloai']; }
	if($_POST['tb_tenloai'] == "") { echo "Please enter your type name"; }
	else{ $c = $_POST['tb_tenloai']; }
	
	if($t!="" && $c!="")
	{
		$sql = "update type_category set maloai='".$t."', tenloai='".$c."' where maloai='".$id."'";
		mysql_query($sql);
		header("location: main_manager.php");
		exit();
 	}
}

?>
<div id="box">
<h3>Quản lý thể loại</h3>
<form class="fr_manage_type" name="fr_manage_type" action="edit_type.php?typeid=<?=$id?>" method="post">
    
    Mã Loại : <input type="text" name="tb_maloai" size="20" value="<?=$row['maloai']?>"  /> <br />
    Tên Loại : <input type="text" name="tb_tenloai"  value="<?=$row['tenloai']?>"  /> <br />
    <input type="submit" name="ok" value="Cập Nhật"  />
        
</form>
</div>
<?
include("includes/sidebar.php");
include("includes/footer.php");
?>